<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/3/12
  Time: 18:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page isELIgnored="false" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <title>修改电话</title>
<style>
    .parent{
        margin-top: 10%;
        margin-left: 30%;
    }
    .title_text{
        margin-top: 20px;
    }
</style>
</head>
<body>
    <div class="parent">
        <input value="${phone.id}" style="display: none" id="id">
        <div class="title_text">
            手机号：<input type="text" value="${phone.phoneNumber}" id="phoneNumber"/>
        </div>
        <div class="title_text">
            姓名：<input type="text" value="${phone.phoneName}" id="phoneName"/>
        </div>
        <div  class="title_text">
            <select id="isEnable">
                    <option value="0">已启用</option>
                    <option value="1" selected>未启用</option>
            </select>
        </div>
        <div class="title_text">
            <button onclick="updateNumber()">修改</button>
        </div>

    </div>
    <script type="text/javascript" src="${path}/webapp/js/jquery-3.1.1.js"></script>
<script type="text/javascript">
    function updateNumber() {

        var id=$("#id").val();
        var phoneNumber=$("#phoneNumber").val();
        var phoneName=$("#phoneName").val();
        var isEnable=$("#isEnable").val();
        $.ajax({
            url:'${path}/sys/phone/updatePhone',
            data:{
               'id':id,
               'phoneNumber':phoneNumber,
               'phoneName' :phoneName,
                'isEnabled':isEnable
                },
            dataType:'json',
            type:'post',
            success:function (data) {
                if(data=='2'){
                    alert("手机号已存在");
                }else if(data=='0'){
                    alert("修改失败");
                }else if(data =='3'){
                    alert("手机号格式不正确");
                }else{
                    alert("修改成功");
                     window.parent.loadHtml('${path}/sys/phone/intoPhone')
                    window.close();
                }
            },
            error:function () {
                alert("服务器正忙。。。");
            }
        })
    }
</script>
</body>
</html>
